package org.nmgyjt.springboot.controller;

import org.nmgyjt.springboot.entity.ApiRes;
import org.nmgyjt.springboot.entity.expert.ExpertInfo;
import org.nmgyjt.springboot.entity.storeInfo.StoreInfo;
import org.nmgyjt.springboot.service.ExpertService;
import org.nmgyjt.springboot.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cs/expert")
public class ExpertController {

    @Autowired
    private ExpertService expertService;

    @GetMapping("/getById")
    public ApiRes getById(Long id) {
        return ApiRes.ok(expertService.getById(id));
    }

    @GetMapping("/getByUserId")
    public ApiRes getByUserId(String userId) {
        return ApiRes.ok(expertService.getByUserId(userId));
    }

    @PostMapping("/saveOrUpdate")
    public ApiRes saveOrUpdate(@RequestBody List<ExpertInfo> expertInfoList) {
        return expertService.insertOrUpdate(expertInfoList);
    }

    @GetMapping("/list")
    public ApiRes list(String depId) {
        return ApiRes.ok(expertService.list());
    }
}
